package com.chj.jz.dp.class04;

public class Code04_CoinsInALine {
	/**
     * @param n: An integer
     * @return: A boolean which equals to true if the first player will win
     */
    public static boolean firstWillWin(int n) {
        // write your code here
    	
    	if(n == 0) {
    		return false;
    	}
    	
    	if(n == 1) {
    		return true;
    	}
    	
    	boolean[] f = new boolean[n + 1];
    	int i;
    	f[0] = false;
    	f[1] = true;
    	for(i = 2; i <= n; i++) {
    		f[i] = (!f[i - 1]) || (!f[i - 2]);
    	}
    	
    	for(i = 0; i <= n; i++) {
    		System.out.println(i + ": " + f[i]);
    	}
    	
    	return f[n];
    }
    
    public static void main(String[] args) {
		{
			System.out.println(firstWillWin(1));
		}
		{
         	System.out.println(firstWillWin(4));
		}
	}
}
